import java.util.Arrays;
import java.util.Scanner;

public class test6 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = in.nextInt();
        }
        int target = in.nextInt();
        System.out.println(Arrays.toString(find(arr, target)));
    }
//    public static int minCostClimbingStairs(int[] cost) {
//        // write code here
//        // 数组的最后一位不是顶楼
//        int n = cost.length;
//        int[] dp = new int[n+1];
//        // dp[i] = 最小值
//        dp[0] = 0;dp[1] = 0;
//        for(int i=2;i<=n;i++){
//            dp[i] = Math.min(dp[i-2]+cost[i-2],dp[i-1]+cost[i-1]);
//        }
//        return dp[n];
//    }


    public static int[] find(int[] nums, int target) {
        // write code here
        // 找数字的区间
        int n = nums.length;
        int left=0,right = n-1;
        int[] result = new int[]{-1,-1};
        if(n==0) return result;
        //先找左开头
        while (left<right){
            int mid = left+(right-left)/2;
            if(nums[mid]<target) left = mid+1;
            else right = mid;
        }
        if(nums[left]==target) result[0] = left;
        // 找右边开头
        left = 0;right = n-1;
        while (left<right){
            int mid = left+(right-left+1)/2;
            if(nums[mid]>target) right = mid-1;
            else left = mid;
        }
        if(nums[right]==target) result[1] = right;
        return result;
    }



}
